package com.google.cbmgraph;

import com.google.cbmgraph.MenuFragment.OnGraphSelectedListener;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;

public class MainFragmentView  extends FragmentActivity implements
OnGraphSelectedListener{
	/**
	 * when created do this 
	 */
	@Override
	 public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fragment_main);
	   }
	
	public void onGraphSelected(String name) {
		Log.d("MainActivity", name+" was picked");
	    GraphView viewer = (GraphView) getSupportFragmentManager()
	            .findFragmentById(R.id.GraphFragment);

	    if (viewer == null || !viewer.isInLayout()) {
	    	Log.d("MenuActivity", "Trying to start GraphView");
	    	Intent intent = new Intent();
	        intent.setClass(getApplicationContext(),GraphActivity.class);
	        startActivity(intent);
	    } else {
	    	Log.d("MainActivity", "I'm in a fragment");
	    }
	}
}
